{include file="public/header" /}

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>添加部门</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal" name="add_offer" id="add_offer" method="post" action="{:url('add_offer')}">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">学历名称：</label>
                                <div class="input-group col-sm-4">
                                    <input id="offer_name" type="text" class="form-control" name="offer_name">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3">
                                    <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                    <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {include file="public/footer" /}

    <script type="text/javascript">
        $(function() {
            $('#add_offer').ajaxForm({
                beforeSubmit: checkForm,
                success: complete,
                dataType: 'json'
            });

            function checkForm() {
                if ('' == $.trim($('#offer_name').val())) {
                    layer.msg('请输入部门名称', {
                        icon: 2,
                        time: 1500,
                        shade: 0.1
                    }, function(index) {
                        layer.close(index);
                    });
                    return false;
                }
            }

            function complete(data) {
                if (data.code == 1) {
                    layer.msg(data.msg, {
                        icon: 6,
                        time: 1500,
                        shade: 0.1
                    }, function(index) {
                        window.location.href = "{:url('member/offer')}";
                    });
                } else {
                    layer.msg(data.msg, {
                        icon: 5,
                        time: 1500,
                        shade: 0.1
                    });
                    return false;
                }
            }
        });



        //IOS开关样式配置
        var elem = document.querySelector('.js-switch');
        var switchery = new Switchery(elem, {
            color: '#1AB394'
        });
        var config = {
            '.chosen-select': {},
        }
        for (var selector in config) {
            $(selector).chosen(config[selector]);
        }
    </script>
</body>

</html>